package com.zyit.controller;

import com.zyit.model.Registry;
import com.zyit.service.RegistryService;
import com.zyit.service.ScheduleService;
import com.zyit.util.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/registry")
public class RegistryController {

    @Resource
    private RegistryService registryService;
    @Resource
    private ScheduleService scheduleService;

    @PostMapping("/add")
    public Result add(Registry registry) {
        int i = registryService.add(registry);
        if (i == 1) {
            scheduleService.updateNum(registry.getScheduleId());
        }
        return new Result(i, i, "");
    }
}
